<?php

namespace addon\fenxiao\event;

use addon\fenxiao\model\FenxiaoOrder;

/**
 * 活动类型
 */
class OrderSettlement
{

    /**
     * 活动类型
     * @param $data
     * @return array
     */
    public function handle($data)
    {
        // 查询所有未结算的股东分红
        try {
            $list = (new LianReward())->where('status', '=', 1)->select();

            if(!$list->isEmpty()){
                $ids = array_column($list->toArray(), 'id');
                (new CoreLianSettleService())->handleQueue($ids);
            }

            Log::write('链动奖励结算发放任务执行成功');
            return true;
        } catch (\Exception $e) {
            Log::write('链动奖励结算发放任务执行失败: ' . $e->getMessage());
            return false;
        }
    }
}